<?php
include('../../inc/global.inc');
include("../islogin.php");
?>
<?php
if($_POST[tj_act]){
mysql_query("insert into link (type_id,link_name,link_web,link_tj) values ('$_POST[link_type_id]','$_POST[link_name]','$_POST[link_web]','$_POST[link_tj]')");
echo "<script>alert('添加成功');location='index.php';</script>";
}
?>
<?php
if($_POST['xg_act']){
mysql_query("update link set type_id='$_POST[link_type_id]',link_name='$_POST[link_name]',link_web='$_POST[link_web]',link_tj='$_POST[link_tj]' where id='".$_POST['iid']."'");
echo "<script>alert('修改成功');location='index.php';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
<table width="700" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">友情链接&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
  <?php
  if($_GET[tj]){
  ?>
<table width="700" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#000000" >
<form action="" method="post" name="form1">
	<tr align='center' bgcolor='#D8EAF4'>
	  <td height="35" colspan="2" valign="middle" nowrap bgcolor="#8DA8CF" class='category'>添加链接</td>
	</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td width="162" align="center" bgcolor="#8DA8CF">选择分类</td>
  <td width="519" align="left" bgcolor="#FFFFFF" style="padding-left:5px"><label>
    <select name="link_type_id">
	<option value="">--选择分类--</option>
<?php
$sql="select * from link_type order by id asc";
$rs=mysql_query($sql);
while($row=mysql_fetch_array($rs)){
?>
	<option value="<?=$row['id']?>"><?=$row[link_class]?></option>
<?php
}?>
    </select>
  </label></td>
</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td align="center" bgcolor="#8DA8CF">链接名称</td>
  <td width="519" align="left" bgcolor="#FFFFFF" style="padding-left:5px"><input name="link_name" type="text" size="20"></td>
</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td align="center" bgcolor="#8DA8CF">链接地址</td>
  <td align="left" bgcolor="#FFFFFF" style="padding-left:5px"><input name="link_web" type="text" value="http://" size="40"></td>
</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td align="center" bgcolor="#8DA8CF">是否推荐</td>
  <td align="left" bgcolor="#FFFFFF" style="padding-left:5px"><input name="link_tj" type="radio" value="1" checked>
  推荐
  <input name="link_tj" type="radio" value="0">
  不推荐&nbsp;<font color="#FF0000">注:推荐在首页显示</font></td>
</tr>
  <tr align='center' bgcolor='#FFFFFF'><input type="hidden" name="tj_act" value="ok">
  <td colspan="2"><input type="submit" value="添加"></td>
  </tr>
  </form>
</table>
<?php }?>

  <?php
  if($_GET['xg']){
  $row=mysql_fetch_array(mysql_query("select * from link where id='".$_GET['xg_id']."'"));
  ?>
<table width="700" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#000000" >
<form action="" method="post" name="form1">
	<tr align='center' bgcolor='#D8EAF4'>
	  <td height="35" colspan="2" valign="middle" nowrap bgcolor="#8DA8CF" class='category'>修改信息</td>
	</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td width="162" align="center" bgcolor="#8DA8CF">选择分类</td>
  <td width="519" align="left" bgcolor="#FFFFFF" style="padding-left:5px">
  <select name="link_type_id">
    <option value="">--选择分类--</option>
 <?php
$sql2="select * from link_type order by id asc";
$rs2=mysql_query($sql2);
while($row2=mysql_fetch_array($rs2)){
?>
<option value="<?=$row2['id']?>" <?php if($row2[id]==$row[type_id]){echo "selected='selected'";}?>><?=$row2[link_class]?></option>
<?php }?>
  </select></td>
</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td align="center" bgcolor="#8DA8CF">链接名称</td>
  <td width="519" align="left" bgcolor="#FFFFFF" style="padding-left:5px"><input name="link_name" type="text" size="20" value="<?=$row[link_name]?>"></td>
</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td align="center" bgcolor="#8DA8CF">链接地址</td>
  <td align="left" bgcolor="#FFFFFF" style="padding-left:5px"><input name="link_web" type="text" value="<?=$row[link_web]?>" size="40"></td>
</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td align="center" bgcolor="#8DA8CF">是否推荐</td>
  <td align="left" bgcolor="#FFFFFF" style="padding-left:5px"><input name="link_tj" type="radio" value="1" <?php if($row[link_tj]==1){echo "checked";}?>>
  推荐
  <input name="link_tj" type="radio" value="0" <?php if($row[link_tj]==0){echo "checked";}?>>
  不推荐&nbsp;<font color="#FF0000">注:推荐在首页显示</font></td>
</tr><input type="hidden" name="iid" value="<?=$row['id']?>">
  <tr align='center' bgcolor='#FFFFFF'><input type="hidden" name="xg_act" value="ok">
  <td colspan="2"><input type="submit" value="修改"></td>
  </tr>
  </form>
</table>
<?php }?>
</center>
</BODY>
</HTML>

